﻿namespace Cos.Module.CMS.Data
{
    using System.Collections.Generic;

    using Cos.Core.Model.Common;
    using Cos.Core.Model.Content;

    public interface IPageRepository
    {
        /// <summary>
        /// Verify if a page exists for a culture and a navId.
        /// </summary>
        /// <param name="cultureVo">The culture of the page.</param>
        /// <param name="pageId">The id of the page.</param>
        /// <param name="isLiveMode">is set to <c>true</c> [viewing the site in live mode].</param>
        /// <returns>true if the page exists, false otherwise</returns>
        bool Exist(Culture cultureVo, int pageId, bool isLiveMode);

        /// <summary>
        /// Gets the page.
        /// </summary>
        /// <param name="pageId">The node we want the page from.</param>
        /// <returns>Page entity</returns>
        Page GetPage(int pageId);

        /// <summary>
        /// Gets the page.
        /// </summary>
        /// <param name="cultureId">The culture we want the page in.</param>
        /// <param name="navId">The node we want the page from.</param>
        /// <returns>Page entity</returns>
        Page GetPage(int cultureId, int navId);

        /// <summary>
        /// Gets the page.
        /// </summary>
        /// <param name="cultureCode">The culture we want the page in.</param>
        /// <param name="navId">The node we want the page from.</param>
        /// <returns>Page entity</returns>
        Page GetPage(string cultureCode, int navId);

        /// <summary>
        /// List of visible supages of a page.
        /// </summary>
        /// <param name="parentPageId">The node we want the sub pages from.</param>
        /// <returns>Subpages collection</returns>
        IEnumerable<Page> GetSubPages(int parentPageId);

        /// <summary>
        /// List of visible supages of a page.
        /// </summary>
        /// <param name="cultureId">The culture we want the sub pages in.</param>
        /// <param name="navId">The node we want the sub pages from.</param>
        /// <returns>Subpages collection</returns>
        IEnumerable<Page> GetSubPages(int cultureId, int navId);

        /// <summary>
        /// List of visible supages of a page.
        /// </summary>
        /// <param name="cultureCode">The culture we want the sub pages in.</param>
        /// <param name="navId">The node we want the sub pages from.</param>
        /// <returns>Subpages collection</returns>
        IEnumerable<Page> GetSubPages(string cultureCode, int navId);

        /// <summary>
        /// List of pages of a certain template.
        /// </summary>
        /// <param name="templateName">The template we want the pages for.</param>
        /// <param name="cultureId">The culture we want the pages for.</param>
        /// <returns>Page collection</returns>
        IEnumerable<Page> GetTemplatePages(string templateName, int cultureId);

        /// <summary>
        /// List of pages of a certain template.
        /// </summary>
        /// <param name="templateName">The template we want the pages for.</param>
        /// <param name="cultureCode">The culture we want the pages for.</param>
        /// <returns>Page collection</returns>
        IEnumerable<Page> GetTemplatePages(string templateName, string cultureCode);

        /// <summary>
        /// Returns the chain of child-parent-grand parent-... navs leading to the root nav
        /// </summary>
        /// <param name="navId">The nav we want the chain for.</param>
        /// <returns>The chain linking the nav to the root</returns>
        IEnumerable<Nav> GetNavChain(int navId);
        
        /// <summary>
        /// Saves a page (nav).
        /// </summary>
        /// <param name="page">The page to save.</param>
        /// <returns>The saved page</returns>
        Page SavePage(Page page);
        
        /// <summary>
        /// Deletes the page.
        /// </summary>
        /// <param name="page">The deleted page.</param>
        void DeletePage(Page page);
    }
}
